#ifndef OPTIONSIFACES_H
#define OPTIONSIFACES_H

#include <QObject>
#include <QDeclarativeView>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QFile>

#include "qnmsettings.h"
#include "ifaceItemModel.h"
#include "ifaceListModel.h"
#include "utils.h"

class OptionsIfaces : public QObject
{
    Q_OBJECT

    //Q_PROPERTY(QObject* cppModelListIfaces READ getModelListIfaces NOTIFY listModelIfacesChanged)

    QNMSettings *qset_this;
    IfaceListModel *listModelIfaces;
    QObject *parent;

    QDeclarativeContext* rootContext;
    QObject * pageNetworkInterfaces;

    inline QString fileData( const QString& path_file ) const
    {
        QString ret = "";

        QFile file( path_file );
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            return ret;
        }
        QTextStream in(&file);
        ret = in.readLine();
        file.close();
        return ret;
    }
    void myRootContext();
    QStringList getIpIface( const QString &iface ) const;
    void clearListIfacesModel();
public:
    explicit OptionsIfaces( QNMSettings * qset, QObject *parent = 0);
    ~OptionsIfaces();

    QObject *getModelListIfaces() {
        return listModelIfaces;
    }
    
signals:
    void listModelIfacesChanged();
    
public slots:
    Q_INVOKABLE void initListIfaces();
    Q_INVOKABLE void initIfconfig();
    Q_INVOKABLE void addIface( const QString &ifaceName );
    Q_INVOKABLE void removeIface( const int ifaceIndex );
    
};

#endif // OPTIONSIFACES_H
